package com.example.my0612zuoye;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerTabStrip;
import androidx.viewpager.widget.ViewPager;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    MyAdapter adapter;
    List<View> list;
    ViewPager pager;
    PagerTabStrip strip;
    String[] title;
    private PagerTabStrip str;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        str = (PagerTabStrip) findViewById(R.id.str);
        pager=findViewById(R.id.pager);
        list=new ArrayList<>();
        View view=LayoutInflater.from(this).inflate(R.layout.item2,null);
        list.add(LayoutInflater.from(this).inflate(R.layout.item1,null));
        list.add(view);
        ImageView img=view.findViewById(R.id.img);
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            Intent intent=new Intent(MainActivity.this,Main2Activity.class);
            startActivity(intent);
            }
        });
        title=new String[]{"首页","跳转"};
        adapter=new MyAdapter(list,title);
        pager.setAdapter(adapter);
    }
}
